package com.lyf.design.learn.designmodel.singleton;

/**
 * @AUTHOR LYF
 * @DATE 2022/6/1
 * @VERSION 1.0
 * @DESC
 * 饿汉式+加锁（粗粒度的加锁）
 * 开销过大
 */
public class Main4 {
    // 需要加volatile? 防止重排问题？？
    private static  Main4 INSTANCE;//new Main4();
    private Main4(){}
    synchronized static Main4 getInstance(){
        if(INSTANCE==null)
            INSTANCE = new Main4();
        return INSTANCE;
    }
    void method(){}
}
